﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;
using Bussiness;
using Model;

namespace hostal
{
    public partial class ModificarHabitacion : Form
    {
        string id;
        private void callFormsChild(Form form)
        {
            form.MdiParent = this.MdiParent;
            form.Show();
            this.Close();
        }

        public ModificarHabitacion(string hab)
        {
            InitializeComponent();
            habitacionDataAccess hDal = new habitacionDataAccess();
            DataTable temp = hDal.buscarHabitacionNum(hab);
            this.num.Text = temp.Rows[0]["numero"].ToString();
            this.tip.Text = temp.Rows[0]["tipo"].ToString();
            this.cap.Text = temp.Rows[0]["capacidad"].ToString();
            id = temp.Rows[0]["rowid"].ToString();
        }



        private void ModificarHabitacion_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                habitacion hab = new habitacion(id,this.num.Text, this.tip.Text, this.cap.Text);
                manejadorHabitacion.ModificarHabitacion(hab);
                MessageBox.Show("Se modifico la habitacion.");
                //this.Close();
                BuscarHabitacion m = new BuscarHabitacion();
                callFormsChild(m);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }
    }
}
